<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                xmlns:ds="http://deltaset.org/deltaset-faces"
                xmlns:mi="http://java.sun.com/jsf/composite/deltaset.meta/flow"
                xmlns:composite="http://java.sun.com/jsf/composite">
    <composite:interface>
        <composite:attribute name="metaAction" required="true"/>
        <composite:attribute name="model" required="true"/>        
        <composite:attribute name="meta" required="true"/>
		<composite:attribute name="recordId"/>

        <composite:attribute name="noVoidShow"  default="formTemplate"/>		

        <composite:attribute name="voidShow"  default="listTemplate"/>
		
        <composite:attribute name="parameterShow"  default="executeTemplate"/>

        <composite:attribute name="style"  default=""/>
    </composite:interface>

    <composite:implementation>

        <c:set var="action" value="#{cc.attrs.metaAction}"/>

        <h:commandButton value="#{cc.attrs.meta.labelAction(action)}"
                         action="#{cc.attrs.meta.loadExecutor(action,cc.attrs.model)}"
                         disabled="#{cc.attrs.meta.isDisabled(action,cc.attrs.model)}"
                         rendered="#{not cc.attrs.meta.isHidden(action,cc.attrs.model)}"
                         styleClass="#{(true==action.enableWarn)?'ds-button ui-state-highlight':'ds-button'}"
                         style="#{cc.attrs.style}}"
                         >
            <c:if test="#{action.enableWarn}">
                <f:attribute name="onclick" value="return deltaset.confirm(this,'execute #{cc.attrs.meta.labelAction(action)} ?');"/>
            </c:if>
			<f:ajax execute="@this @form" render="@form"/>
            <c:if test="#{not action.hasParameter}">
                <!-- what if returning entity -->
                <c:if test="#{not action.isReturningVoid}">                    
					<f:param name="showView" value="#{cc.attrs.noVoidShow}"/>
                </c:if>
                <c:if test="#{action.isReturningVoid}">                  
                    <f:param name="showView" value="#{cc.attrs.voidShow}"/>					
                </c:if>
            </c:if>
            <c:if test="#{action.hasParameter}">
                <f:param name="showView" value="#{cc.attrs.parameterShow}"/>				
            </c:if>
            <c:if test="#{not empty cc.attrs.recordId}">			
                <f:param name="recordId" value="#{cc.attrs.recordId}"/>
            </c:if>			
        </h:commandButton>      

    </composite:implementation>

</ui:composition>
